import java.util.Arrays;

/**
 * @ClassName LC645
 * @Author ykx
 * @Date 2024/6/30 8:38
 * @Version 1.0
 */
public class LC645 {
    public static void main(String[] args) {
        LC645 lc645 = new LC645();
        System.out.println(Arrays.toString(lc645.findErrorNums(new int[]{1, 1})));
    }

    public int[] findErrorNums(int[] nums) {
        int[] mapping = new int[nums.length];
        int[] result = new int[2];

        for (int num : nums) {
            mapping[num - 1]++;
        }

        for (int i = 0; i < nums.length; i++) {
            if (mapping[i] == 0) {
                result[1] = i + 1;
            } else if (mapping[i] == 2) {
                result[0] = i + 1;
            }
        }

        return result;
    }

}
